<!DOCTYPE HTML>
<!--generated with sswg-->
<html lang="en">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
    <title> ursina engine documentation</title>
    <link rel="stylesheet" href="sswg.css">
    <link rel="stylesheet" href="style.css">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<div style="max-width:1200px; margin:auto;">
<div style="text-align:left;">
<br>
<a href="index.html"><img src="ursina_logo_wireframe.webp" style="width:50px; height:auto; margin-right:10px;"/></a> <a href=" installation.html" class="button">Download</a> <a href=" documentation.html" class="button">Documentation</a> <a href=" api_reference_v8_2_0/index.html" class="button">API Reference</a> <a href=" samples.html" class="button">Samples</a> <a href=" asset_store.html" class="button">Asset Store</a> <a href=" donate.html" class="button">Donate</a><br>
<h1 id="Platformer">
Platformer
</h1><a href="https://github.com/pokepetter/ursina/blob/master/samples/platformer.py">https://github.com/pokepetter/ursina/blob/master/samples/platformer.py</a><br>
<br>
<img src="icons/platformer.jpg"></img> <br>
<code_block id="code_block_0"><button class="copy_code_button" onclick="copy_to_clipboard(code_block_0)">copy</button><purple>from</purple> ursina <purple>import</purple> *
<purple>from</purple> ursina.prefabs.platformer_controller_<yellow>2</yellow>d <purple>import</purple> PlatformerController<yellow>2</yellow>d

app = Ursina()
window.color = color.light_gray
camera.orthographic = True
camera.fov = <yellow>2</yellow><yellow>0</yellow>
ground = <olive>Entity</olive>(<olive>model</olive>=<green>'cube'</green>, <olive>color</olive>=color.olive.tint(-.<yellow>4</yellow>), <olive>z</olive>=-.<yellow>1</yellow>, <olive>y</olive>=-<yellow>1</yellow>, origin_<olive>y</olive>=.<yellow>5</yellow>, <olive>scale</olive>=(<yellow>1</yellow><yellow>0</yellow><yellow>0</yellow><yellow>0</yellow>,<yellow>1</yellow><yellow>0</yellow><yellow>0</yellow>,<yellow>1</yellow><yellow>0</yellow>), <olive>collider</olive>=<green>'box'</green>, <olive>ignore</olive>=True)

random.seed(<yellow>4</yellow>)
<purple>for</purple> i in <blue>range</blue>(<yellow>1</yellow><yellow>0</yellow>):
&nbsp;&nbsp;&nbsp;&nbsp;<olive>Entity</olive>(<olive>model</olive>=<green>'cube'</green>, <olive>color</olive>=color.dark_gray, <olive>collider</olive>=<green>'box'</green>, <olive>ignore</olive>=True, <olive>position</olive>=(random.randint(-<yellow>2</yellow><yellow>0</yellow>,<yellow>2</yellow><yellow>0</yellow>), random.randint(<yellow>0</yellow>,<yellow>1</yellow><yellow>0</yellow>)), <olive>scale</olive>=(random.randint(<yellow>1</yellow>,<yellow>2</yellow><yellow>0</yellow>), random.randint(<yellow>2</yellow>,<yellow>5</yellow>), <yellow>1</yellow><yellow>0</yellow>))

player = PlatformerController<yellow>2</yellow>d()
player.x = <yellow>1</yellow>
player.y = raycast(player.world_position, player.down).world_point[<yellow>1</yellow>] + .<yellow>0</yellow><yellow>1</yellow>
camera.add_script(SmoothFollow(target=player, offset=[<yellow>0</yellow>,<yellow>5</yellow>,-<yellow>3</yellow><yellow>0</yellow>], speed=<yellow>4</yellow>))


input_handler.bind(<green>'right arrow'</green>, <green>'d'</green>)
input_handler.bind(<green>'left arrow'</green>, <green>'a'</green>)
input_handler.bind(<green>'up arrow'</green>, <green>'space'</green>)
input_handler.bind(<green>'gamepad dpad right'</green>, <green>'d'</green>)
input_handler.bind(<green>'gamepad dpad left'</green>, <green>'a'</green>)
input_handler.bind(<green>'gamepad a'</green>, <green>'space'</green>)

<purple>if</purple> application.development_mode:&nbsp;&nbsp;&nbsp;&nbsp;<gray># cheats</gray>
&nbsp;&nbsp;&nbsp;&nbsp;<purple>from</purple> ursina.scripts.noclip_mode <purple>import</purple> NoclipMode<yellow>2</yellow>d
&nbsp;&nbsp;&nbsp;&nbsp;player.add_script(NoclipMode<yellow>2</yellow>d())

app.run()

</code_block>
<script>
function copy_to_clipboard(containerid) {
    var range = document.createRange()
    range.selectNode(containerid)
    window.getSelection().removeAllRanges()
    window.getSelection().addRange(range)
    document.execCommand("copy")
    window.getSelection().removeAllRanges()
}
</script>
<br>
<br>
</body>
</html>